home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / kaffe / main.c < prev    next >
C/C++ Source or Header  |  1996-02-12  |  1KB  |  66 lines

  1. /*
  2.  * main.c
  3.  * Kick off program.
  4.  *
  5.  * Copyright (c) 1996 Systems Architecture Research Centre,
  6.  *           City University, London, UK.
  7.  *
  8.  * See the file "license.terms" for information on usage and redistribution
  9.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10.  *
  11.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  12.  */
  13.  
  14. #include <stdio.h>
  15. #include <assert.h>
  16. #include "gtypes.h"
  17. #include "classMethod.h"
  18. #include "baseClasses.h"
  19. #include "lookup.h"
  20. #include "object.h"
  21. #include "thread.h"
  22.  
  23. #define    MAIN        "main"
  24. #define    MAINSIG        "([Ljava/lang/String;)V"
  25.  
  26. extern classes* StringClass;
  27.  
  28. /*
  29.  * MAIN
  30.  */
  31. main(int argc, char* argv[])
  32. {
  33.     classes* class;
  34.     void* func;
  35.     object* args;
  36.     stringClass** str;
  37.     int i;
  38.  
  39.     /* Get the class name to start with */
  40.     if (argc < 2) {
  41.         fprintf(stderr, "No class specified.\n");
  42.         exit(1);
  43.     }
  44.  
  45.     /* Convert any '.' in name to '/' */
  46.     classname2pathname(argv[1], argv[1]);
  47.  
  48.     /* Initialise */
  49.     initialise();
  50.  
  51.     /* Build an array of strings as the arguments */
  52.     args = alloc_objectarray(argc-2, StringClass->sig);
  53.  
  54.     /* Build each string and put into the array */
  55.     str = (stringClass**)args->data;
  56.     for (i = 2; i < argc; i++) {
  57.         str[i-2] = (stringClass*)makeJavaString(argv[i], strlen(argv[i]));
  58.     }
  59.  
  60.     /* Kick it */
  61.     do_execute_java_class_method(argv[1], MAIN, MAINSIG, args);
  62.     killThread(currentThread);
  63.     /* This should never return */
  64.     exit(1);
  65. }
  66.